/**
 * @Project RSLsXWG
 * @Author Tran Manh Hung
 * @Email: hungtmit@gmail.com | tmh@xwebgate.com
 * @Copyright © 2011 TMH. All rights reserved
 * @Createdate Jun 15, 2011
 * @Createtime 4:34:23 PM
 */

package com.gigalaxy.game.card
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.geom.Point;
	import flash.geom.Rectangle;

	import flashx.textLayout.debug.assert;

	public class CardFaceAAA extends Sprite
	{
		private var _canvas:BitmapData;
		private var _img:Bitmap;

		/*
		private var CARD_WIDTH:uint = 192;
		private var CARD_HEIGHT:uint = 256;
		//*/

		//*
		private var CARD_WIDTH:uint = 192;
		private var CARD_HEIGHT:uint = 256;

		//*/

		public function CardFaceAAA()
		{
			super();

			_canvas = new BitmapData(CARD_WIDTH, CARD_HEIGHT);
			_img = new Bitmap(_canvas);
			_img.smoothing = true;

			addChild(_img);
		}

		/**
		 * position from 1 to 52
		 */
		public function gotoAndStop(position:int):void
		{
			var xPos:uint = ((position - 1) % 13) * CARD_WIDTH;
			var yPos:uint = Math.floor((position - 1) / 13) * CARD_HEIGHT;

			_canvas.lock();
			_canvas.copyPixels(CardAssets._cardsSheet, new Rectangle(xPos, yPos, CARD_WIDTH, CARD_HEIGHT), new Point(0, 0));
			_canvas.unlock();
		}
	}
}


